<template>
	<view>
		<uni-section title="历史记录" type="line">
			<uni-list v-for="(item,index) in listData" :key="index">
				<uni-list-item v-if="item.rwwczt =='0'" clickable @click="tzym(item)" :title="item.rwmc" :note="item._add_time_str" rightText="未打卡" style="color: #FF5722;"/>
				<uni-list-item v-if="item.rwwczt =='1'" clickable @click="tzym(item)" :title="item.rwmc" :note="item._add_time_str" rightText="已打卡" style="color: #09BB07;"/>
			</uni-list>
		</uni-section>
	</view>
</template>


<script>
	import uniList from "@/pages_bd/components/uni-list/uni-list";
	import UniListItem from "@/pages_bd/components/uni-list-item/uni-list-item";
	var _this;
	var vk = uni.vk;
	export default {
		components: {uniList,UniListItem},
		data() {
			// 页面数据变量
			return {
				options:{},
				opid:'',
				listData: [],
				valiFormData:{}
			}
		},
		// 监听 - 页面每次【加载时】执行(如：前进)
		async onLoad(options = {}) {
			_this = this;
			vk = uni.vk;
			this.options = options;
			this.init(options);
			//let userinfo = vk.getVuex('$user.userInfo')
			//_this.opid = vk.getVuex('$user.userInfo.wx_openid.mp-weixin')
			const value = uni.getStorageSync('xmt-xs-dl-key');
			if (value) {
				this.valiFormData = value;
			}
			await this.getxmtdkList()

		},
		// 监听 - 页面【首次渲染完成时】执行。注意如果渲染速度快，会在页面进入动画完成前触发
		onReady(){
			
		},
		// 监听 - 页面每次【显示时】执行(如：前进和返回) (页面每次出现在屏幕上都触发，包括从下级页面点返回露出当前页面)
		onShow() {
			
		},
		// 监听 - 页面每次【隐藏时】执行(如：返回)
		onHide() {
			
		},
		// 监听 - 点击右上角转发时
		onShareAppMessage(options) {
			
		},
		// 函数
		methods: {
			addWxryWzListOneppp(){
				// promise方式

			},
			dyxx(){
				uni.requestSubscribeMessage({
				  tmplIds: ['FII6eFIVp7TYzIDchcREgsA9Nj9JffLL_4u6ZAgikyo'],
				  success (res) {
					  //console.log(res) 订阅新媒体打卡
				  },fail(fail){
					   //console.log(fail)
				  }
				})
			},
			tzym(item){
					// uni.setStorageSync('tzym-xs-key',item);
					// this.dyxx();
					// vk.redirectTo('/pages_bd/xmt_xs/xmtdk-xs-from');
				if(item.startTime && item.startTime > Date.now()){
					uni.setStorageSync('tzym-xs-key',item);
					//this.dyxx();
					vk.redirectTo('/pages_bd/xmt_xs/xmtdk-xs-from');
				}else{
					vk.toast("打卡时间已经过了", "none", 3000);
				}

			},
			getxmtdkList(){
				return vk.callFunction({
				  url: 'client/gsxy/xmtdk/pub/xmtdk-xs-api.getxmtdkxsList',
				  title:'请求中...',
				  data:{
				    userid:_this.valiFormData._id
				  }
				}).then(async (data) => {
				  //console.log(data)
				  _this.listData = data.list
				}).catch((err) => {
				  
				});
			},
			// 页面数据初始化函数
			init(options){
				//vk.reLaunch("/pages_template/uni-id/index/index");
			},
			pageTo(path){
				vk.navigateTo(path);
			}
		},
		// 监听器
		watch:{
			
		},
		// 计算属性
		computed:{
			
		}
	}
</script>
<style lang="scss" scoped>
	.example-info {
		/* #ifndef APP-NVUE */
		display: block;
		/* #endif */
		padding: 15px;
		color: #3b4144;
		background-color: #ffffff;
		font-size: 14px;
		line-height: 20px;
	}
	
</style>